<link rel="stylesheet" href="/css/jquery-ui.css" />
<script src="/js/jquery-1.7.2.min.js"></script>
<script src="/js/jquery-ui-1.9.1.custom.min.js"></script>
    <style>
    #sortable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
    #sortable li { margin: 0 5px 5px 5px; padding: 0px; font-size: 1.2em; height: 2.0em; }
    html>body #sortable li { height: 2.0em; line-height: 2.0em; }
    .ui-state-highlight { height: 1.5em; line-height: 1.5em; }
    #sortable li span.stt {width: 30%;}
    </style>
    <script>
    $(function() {
        $( "#sortable" ).sortable({
            placeholder: "ui-state-highlight"
        });
        $( "#sortable" ).disableSelection();
     });
     function sort_menu(){
    		var list = $("#sortable li #ma_id");
    		var temp = "";
    		for(var i=0; i<list.length; i++){
    	  		  if(temp != "")
    		  		  temp += ",";
    	  		  temp += $(list[i]).val();
    		}
            $("#sort-menu").val(temp);
     }
    </script>
<?php 
$list = $this->datas;
if($list){
?>
<div class="grid_9" id="dashtabs">
<form id='myForm' name='myForm' method="post">
<div align="left"><input type="submit" name="submit" class="button" value="Sắp xếp" onclick="sort_menu()"/></div>
<div id="dashtabs-pages" class="box-content no-padding">  
			<ul id="sortable">
			<?php 		
			$key =0;
			foreach ($list as $key => $value) {
				echo "<li class='ui-state-default' id = '".$value['id']."' >";
				?>
				<input type="hidden" id="ma_id" value="<?php echo $value['id']; ?>"/>
				<?php
				echo "<div class='stt' style='width:80px;float: left;margin-left: 10px'>".($key + 1)."</div>";
				echo "<div class='subject_name' style='width:340px;float: left'>".$value['name']."</div>";
                if(!isset($_REQUEST['id'])){
                echo "<a style='color: blue;text-decoration:underline;'href='/admin/type/sorttype?id=".$value['id']."'>Sắp xếp mục nhỏ</a>";
				};
                echo "</li>";
			}
			?>
			</ul>
			<input type="hidden" name="sort-menu" id="sort-menu"/>
    <div id="view"> </div>
</form>
</div>

</div>
<?php 
}
?>